# -*- coding: utf-8 -*-

from manager import singleton
from simple import SimpleDownloader
from phantom import PhantomDownloader
@singleton
class Downloader(object):
    def __init__(self,conf):
        self.conf=conf
        self.downloaders = {
            'simple':  SimpleDownloader(conf),
            'phantom': PhantomDownloader(conf),
        }
    def download(self, req):
        downloader = self.downloaders.get(req.download_type)
        if downloader:
            res= downloader.download(req)
        else:
            res= self.downloaders.get('simple').download(req);
        return res


